package com.coldlz.mmp.proxy;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpResponseStatus;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class HttpRecordResponse implements HttpRecord {

    @JsonSerialize(using = ToStringSerializer.class)
    private HttpResponseStatus status;
    private HttpHeaders httpHeaders;
    private final Map<String, List<String>> headers = new HashMap<>();
    private List<byte[]> content;

    private Integer dbTableId;

    public Integer getDbTableId() {
        return dbTableId;
    }

    public void setDbTableId(Integer dbTableId) {
        this.dbTableId = dbTableId;
    }

    public void addHeader(String key, String value) {
        List<String> strings = headers.computeIfAbsent(key, k -> new LinkedList<>());
        strings.add(value);
    }
    public void addHeader(String key, List<String> value) {
        headers.put(key,value);
    }


    public HttpResponseStatus getStatus() {
        return status;
    }

    public void setStatus(HttpResponseStatus status) {
        this.status = status;
    }

    public List<byte[]> getContent() {
        return content;
    }

    public void setContent(List<byte[]> content) {
        this.content = content;
    }

    public HttpHeaders getHttpHeaders() {
        return httpHeaders;
    }

    public void setHttpHeaders(HttpHeaders httpHeaders) {
        this.httpHeaders = httpHeaders;
    }

    public Map<String, List<String>> getHeaders() {
        return headers;
    }
}